Search
woogc/global_cart/sites - WP Global Cart
17444
documentation-template-default,single,single-documentation,postid-17444,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

woogc/global_cart/sites

WP Global Cart / woogc/global_cart/sites
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

woogc/global_cart/sites

Name: woogc/global_cart/sites
Type: Filter
Arguments: (array) $sites_ids

The following code snippet demonstrates how to synchronize the current shop with only the designated checkout site. This selective synchronization is particularly useful when you want to minimize the number of shops involved in the network, ensuring that only the current site and the checkout site are synced. This approach optimizes performance and reduces unnecessary data transfer, focusing the synchronization process on the essential sites only.

By utilizing the woogc/global_cart/sites filter, you can easily define which sites within the network should be included in the global cart synchronization, providing flexibility and control over your multisite setup.


        add_filter('woogc/global_cart/sites', 'woogc_global_cart_sites');
        function woogc_global_cart_sites( $sites )
            {
                
                $options    =   WooGC_Functions::get_options();
                
                if ( $options['synchronization_type']   !=  'screen' )
                    return $sites;
                    
                if ( $options['cart_checkout_location']  < 1 )
                    return $sites;
                    
                global $blog_id; 
                
                $sites  =   array();
                
                if ( $blog_id != $options['cart_checkout_location'] )
                    $sites  =   array ( $options['cart_checkout_location'] );
                    
                return $sites;    
            }

The code should be placed inside a php file on wp-content/mu-plugins folder.

0
Would love your thoughts, please comment.x
()
x